The sprite track media format is hierarchical and is based on QT atoms and atom containers. A sprite track sample is a flattened QT atom container structure. A new set of Movie Toolbox functions, the QT atom functions, make it easy to create and manipulate data in this format. For more information on QT atoms and atom containers, see "Movie Toolbox: Sprite Toolbox."
Figure 1 shows the high-level structure of a sprite track key frame sample. A key frame sample is represented by a QT atom container. Each atom in the atom container is represented by its atom type, atom ID, and, if it is a leaf atom, the type of its data.
Figure 1 A key frame sample atom container
The QT atom container contains one child atom for each sprite in the key frame sample. Each sprite atom has a type of kSpriteAtomType . The sprite IDs are numbered from one to the number of sprites defined by the key frame sample ( numSprites ). Each sprite atom contains leaf atoms that define the properties of the sprite, as shown in Figure 2 . For example, the kSpritePropertyLayer property defines a sprite's layer. Each sprite property atom has an atom type that corresponds to the property and an ID of 1.
Figure 2 Atoms that describe a sprite and its properties
In addition to a name, each sprite can have a uniform resource locator (URL). The URL is a string stored in an atom of type kSpriteURLLinkAtomType whose ID is 1. The string has no leading length byte and no trailing null. The length of the string is the number of bytes of the atom it is contained in.
In addition to the sprite atoms, the QT atom container contains one atom of type kSpriteSharedDataAtomType with an ID of 1. The atoms contained by the shared data atom describe data that is shared by all sprites. The shared data atom contains one atom of type kSpriteImagesContainerAtomType with an ID of 1 ( Figure 3 ). The image container atom contains one atom of type kImageAtomType for each image in the key frame sample. The image atom IDs are numbered from one to the number of images ( numImages ). Each image atom contains a leaf atom that holds the image data (type kSpriteImageDataAtomType ) and an optional leaf atom (type kSpriteNameAtomType ) that holds the name of the image.
Figure 3 Atoms that describe sprite images
The format of an override sample is identical to that of a key frame sample with the following exceptions.
For example, to define an override sample that modifies the location of the third sprite defined by the previous key frame sample, you would create a QT atom container and add the following atoms to it (assuming that the sprite track format is of type kKeyFrameAndSingleOverride ):
Figure 4An example of an override sample atom container